package com.maoxx.libms.mapper;

import com.maoxx.libms.controller.dto.RecordDto;
import com.maoxx.libms.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2024-10-25
 */

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT \n" +
            "  user.user_id,\n" +
            "  user.user_name,\n" +
            "  user.user_email,\n" +
            "  user.user_status,\n" +
            "  book.book_id,\n" +
            "  book.book_name,\n" +
            "  record.record_id,\n" +
            "  record.record_borrowtime,\n" +
            "  record.record_remandtime\n" +
            "FROM\n" +
            "  USER \n" +
            "  LEFT JOIN record ON record.user_id = user.user_id\n" +
            "  LEFT JOIN book ON record.book_id = book.book_id")
    List<RecordDto> getAllUsersRecord();

    /**
     * 修改借阅者信息
     * @param user 需要修改的借阅者信息
     */
    /*@Update("update user set user_name = #{userName}, " +
            "user_password = #{userPassword}, " +
            "user_status = #{userStatus} " +
            "where user_id = #{userId}")
    void updateUser(User user);*/
}
